Skip to content

Clean up WordPress.com connections for deleted sites - #4350

Merged
bcotrim merged 2 commits into
trunkfrom
mognet/cleanup-wpcom-connections-on-site-delete
Jul 30, 2026
Merged

Clean up WordPress.com connections for deleted sites#4350
bcotrim merged 2 commits into
trunkfrom
mognet/cleanup-wpcom-connections-on-site-delete

Conversation

@bcotrim

@bcotrim bcotrim commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Codex assisted with repository exploration, implementation, focused regression tests, manual shared-config validation, and PR drafting. The final scope and behavior were reviewed during implementation.

Proposed Changes

  • Remove every WordPress.com connection for a deleted local site across account buckets, allowing its remote sites to be connected again.
  • Clean up existing orphaned connections while preserving connections for registered local sites.
  • Keep local site deletion moving when connection cleanup fails.

Testing Instructions

  1. Run npm run typecheck.
  2. Run npm test -- apps/cli/migrations/tests/07-cleanup-orphaned-connected-sites.test.ts packages/common/lib/tests/connected-sites.test.ts apps/cli/commands/site/tests/delete.test.ts.
  3. Connect a disposable local site to WordPress.com, delete it with studio site delete --no-files, and confirm its localSiteId is removed from ~/.studio/shared.json.
  4. With an orphaned connection in shared.json, run studio site list and confirm the migration removes the orphan while preserving connections for registered sites.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this Jul 27, 2026
@wpmobilebot

wpmobilebot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing c47d765 vs trunk

app-size

Metric trunk c47d765 Diff Change
App Size (Mac) 1375.36 MB 1375.36 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk c47d765 Diff Change
load 1070 ms 731 ms 339 ms 🟢 -31.7%

site-startup

Metric trunk c47d765 Diff Change
siteCreation 6512 ms 6497 ms 15 ms ⚪ 0.0%
siteStartup 2392 ms 2379 ms 13 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim
bcotrim marked this pull request as draft July 27, 2026 13:44
@bcotrim
bcotrim requested review from nightnei and sejas July 27, 2026 18:46
@bcotrim
bcotrim marked this pull request as ready for review July 28, 2026 10:31
@nightnei

nightnei commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Connect a disposable local site to WordPress.com

@bcotrim What means disposable?

With an orphaned connection in shared.json

Could you please also elaborate on this part? What are the steps?

@bcotrim

bcotrim commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Connect a disposable local site to WordPress.com

@bcotrim What means disposable?

It's just a local site you don't mind deleting

With an orphaned connection in shared.json

Could you please also elaborate on this part? What are the steps?

In trunk deleting a site would not remove the connection, you could still see it in ~/.studio/shared.json
The steps are:

  1. Create or use a local site you don't mind deleting
  2. Connect to WordPress.com site
  3. Find the connection in ~/.studio/shared.json
  4. Delete the Studio site you create
  5. Confirm ~/.studio/shared.json no longer has that connection

@nightnei nightnei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and works as expected 👍

@bcotrim
bcotrim merged commit e8a9c1c into trunk Jul 30, 2026
13 checks passed
@bcotrim
bcotrim deleted the mognet/cleanup-wpcom-connections-on-site-delete branch July 30, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants